Dashboard Temp Share Shortlinks Frames API

HTMLify

app.js
Views: 15 | Author: huxn-webdev
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
const btn = document.getElementById("btn");
let hex = document.getElementById("hexCode");

function randomColor() {
  let letters = "0123456789ABCDEF";
  let color = "#";
  for (let i = 0; i < 6; i++) {
    color += letters[Math.floor(Math.random() * 16)];
  }
  return color;
}

btn.addEventListener("click", () => {
  document.body.style.backgroundColor = randomColor();
  hex.innerHTML = randomColor();
});